import axios from "axios";
// console.log(import.meta.env);// 是Object
// console.log(import.meta.env.VITE_BASE_URL);
const request = axios.create({
  baseURL: import.meta.env.VITE_BASE_URL,
  timeout: 3000,
  method: "get",
});
request.interceptors.request.use(
  (req) => {
    return req;
  },
  (err) => {
    return Promise.reject(err);
  }
);
request.interceptors.response.use(
  (res) => {
    if (res.status === 200) {
      // console.log(res);
      return res.data;
    } else {
      res.errMsg = "数据响应失败";
      return Promise.reject(res);
    }
  },
  (err) => Promise.reject(err)
);
export default request;
